<template>
  <el-dialog width="50%" title="结算佣金" :visible.sync="dialogVisible" :close-on-click-modal="false">
    <el-form class="ruleForm" :model="form" label-width="100px">
      <el-form-item label="结算佣金">
        <el-input v-model="form.amount" clearable placeholder="输入结算佣金" />
        <p class="type_tip">
          结算总佣金：{{ form.reward_all }}
        </p>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" @click="dialogVisible = false">取 消</el-button>
      <el-button size="small" type="primary" @click="save">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { orderSettleOnce } from '@/api/finance'
export default {
  props: {
    objEdit: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      form: {
        amount: 0,
        reward_all:'',
        order_id:''
      },
      dialogVisible: false
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.init()
        this.getData()
      }
    }
  },
  methods: {
    getData() {
    },
    init() {
      // for (const key in this.form) {
      //   this.form[key] = this.objEdit[key].toString() || ''
      // }
      this.form={
        reward_all:this.objEdit.reward_all,
        order_id:this.objEdit.order_id
      }
    },
    save() {
      const that = this
      this.$confirm('确定结算？', '结算佣金', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        const data = { ...that.form }
        // console.log(data);
        const params = {
          amount:this.form.amount,order_id:this.form.order_id
        }
        orderSettleOnce(params).then(res => {
          this.dialogVisible = false
          this.$message({
            message: '结算成功',
              type: 'success'
          })
          this.$emit('getList', true)
        })
      }).catch(() => { })
    }
  }
}
</script>

<style lang="scss" scoped>
.type_tip {
  color: #999999;
  line-height: 22px;

  span {
    color: #ff4146;
  }
}
</style>
